package com.coder4j.starter.generator.vo;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 代码内容
 * @author keller
 * @date 2025-05-26 16:02:46
 */
@Data
public class CodeContentVO {
    List<FileVO> javaFiles;

    List<FileVO> vueFiles;

    List<FileVO> sqlFiles;


    List<RunLog> logs = new ArrayList<>();

    @Data
    public static class RunLog{
        String title;
        String description;

        public RunLog(String title, String description) {
            this.title = title;
            this.description = description;
        }
    }

    @Data
    public static class FileVO{
        String title;
        String fileName;
        String filePath;
        String projectPath;
        String content;
        String prefix;
        String suffix;
        String fileType;
        String templateFile;
        String markdownContent;

        public String getMarkdownContent(){
            return prefix + content + suffix;
        }

        public FileVO() {
        }

        public FileVO(String title,String fileName, String filePath,String projectPath, String fileType,String templateFile) {
            this.title = title;
            this.fileName = fileName;
            this.filePath = filePath;
            this.fileType = fileType;
            this.projectPath = projectPath;
            this.templateFile = templateFile;
            this.prefix = "```" + fileType + " \n";
            this.suffix = "\n ```";
        }
    }

    public List<FileVO> initJavaFiles(){
        return new ArrayList<FileVO>(){{
            add(new FileVO("Query（查询类）","Query.java","java/vo","vo","java","BaseQuery"));
            add(new FileVO("VO（前端展示类）","VO.java","java/vo","vo","java", "VO"));
            add(new FileVO("EO（Excel导出类）","EO.java","java/vo","vo","java", "EO"));
            add(new FileVO("Mapper","Mapper.java","java/mapper","mapper","java", "BaseMapper"));
            add(new FileVO("Service","Service.java","java/service","service","java", "BaseService"));
            add(new FileVO("Controller","Controller.java","java/controller","controller","java", "BaseController"));
            add(new FileVO("Entity（数据库实体类）","Entity.java","java/entity","entity","java", "BaseEntity"));
        }};
    }

    public List<FileVO> initVueFiles(){
        return new ArrayList<FileVO>(){{
            add(new FileVO("page.js（路由和页面按钮权限定义）","page.js","vue/views/","views/","javascript","Vue3Page"));
            add(new FileVO("index.vue（主页面）","index.vue","vue/views/","views/","vue", "Vue3Index"));
            add(new FileVO("form.vue（表单页）","form.vue","vue/views/","views/","vue", "Vue3Form"));
            add(new FileVO("api.ts（接口定义）","Api.ts","vue/api","api","typescript", "Vue3Api"));
        }};
    }
    public List<FileVO> initSqlFiles(){
        return new ArrayList<FileVO>(){{
            add(new FileVO("","InitMenu.sql","sql","","sql","MenuSql"));
        }};
    }
}
